#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

struct Student

{

    char id[13];

    char name[20];

    char gender;

    struct bir

    {

        int y;

        int m;

        int d;

    }birth;

}st[1001];

int main()

{

    int n = 0;

    scanf("%d", &n);

    for (int i = 0;i < n;i++)

    {

        scanf("%s %s %c %d %d %d", &st[i].id, &st[i].name, &st[i].gender, &st[i].birth.y, &st[i].birth.m, &st[i].birth.d);


    }

    for (int j = 0;j < n;j++)

    {

        if (st[j].birth.m == 1&&st[j].gender == 'F')

        {

            printf("%s %s %c %d %d %d", st[j].id, st[j].name, st[j].gender, st[j].birth.y, st[j].birth.m, st[j].birth.d);
            printf("\n");

        }

    }





    return 0;

}
//
//4
//202016090104 Zhaoling F 2001 1 30
//202016090207 Wangliang M 2002 2 14
//202016090418 Fangfang M 2003 1 30
//202016090529 Liumei  F 2000 1 1